// 封装用户登录接口

import { request } from "@/utils/requests";
import type { User ,CodeType,UserInfo ,PatientList,Patient } from "@/types/user";

export const loginByPasswordAPI = (mobile:string,password:string)=>{
   return request<User>('/login/password','post',{mobile,password})
}

// 封装发送短信验证码接口

export const sendCodeAPI = (mobile:string,type:CodeType)=>{
    return request<User>('/code','get',{mobile,type})
}

// 封装短信验证码登陆
export const loginByCodeAPI = (mobile:string,code:string)=>{
    return request<User>('/code','get',{mobile,code})
}

// 获取个人信息
export const getUserInfo = () => {
    return request<UserInfo>('/patient/myUser')
}

// 获取患者信息列表
export const getPatientList = () => {
    return request<PatientList>('/patient/mylist')
}
// 添加患者信息
export const addPatient = (patient: Patient) => request(
    '/patient/add', 'POST', patient
)
// 编辑患者信息
export const editPatient = (patient: Patient) => request(
    '/patient/update', 'PUT', patient
)
   // 删除患者信息
export const delPatient = (id: string) => request(
    `/patient/del/${id}`, 'DELETE'
)

